package com.ad2campaign.engine.utils;

import com.ad2campaign.engine.db.model.Node;

public enum EngineRestOperation 
{
	
	START("start"),STOP("stop"),RESTART("restart"), FAIL("fail"),STARTED("started"),STOPPED("stopped");
	
 	private String operation ;
	
	EngineRestOperation(String operation)
	{
		this.operation=operation;
	}
	
	public String toRestUrl(Node node)
	{
		return String.format("http://%s:%d/%s",node.getHost(),node.getPort(),operation);
	}

	public String getSuccessResponse()
	{
		if (!operation.endsWith("ed"))
			return operation+"ed";
		else
			return "fetched";
	}
	
	public String getOperationName()
	{
		return operation;
	}
	
}
